package com.only4play.system.web.product;

import com.only4play.common.model.JsonObject;
import com.only4play.productcenter.api.product.service.ProductFeignService;
import com.only4play.productcenter.api.template.request.TemplateCreateRequest;
import com.only4play.system.application.ProductTemplateBasedCreateServiceImpl;
import com.only4play.system.mapper.ProductMapper;
import com.only4play.system.req.ProductCreateReq;
import com.only4play.system.req.template.ProductTemplateBasedCreateReq;
import com.only4play.system.ret.template.ProductRet;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hinzzz www.hinzzz.cn 157957329@qq.com
 * 2024-02-28
 */
@RestController
@RequestMapping(value = "product")
@Schema(title = "产品管理")
@RequiredArgsConstructor
public class ProductController {

    private final ProductTemplateBasedCreateServiceImpl productTemplateBasedCreateService;


    /**
     * 创建产品
     * @param productCreateReq
     * @return
     */
    @PostMapping(value = "createProduct")
    public JsonObject<Long> createProduct(@RequestBody ProductTemplateBasedCreateReq productCreateReq){
        ProductRet productRet = productTemplateBasedCreateService.createTemplateBased(productCreateReq);
        return JsonObject.success(productRet.getPId());
    }

}
